// import * as THREE from "three"
let THREE=require('three');
import {DirectionalLight} from "three";
import {HemisphereLight} from "three";

class LightMgr {


  static getInstance() {
    if (!LightMgr.instance) {
      LightMgr.instance = new LightMgr();
    }
    return LightMgr.instance;
  }

  constructor() {
  }

  //创建灯光
  createLight(lightType) {
    if (lightType == 'DirectionalLight') {
      //太阳
      let sunlight = new DirectionalLight(0xffffff);
      sunlight.position.set(20, 40, 0);
      sunlight.intensity=3;
      sunlight.castShadow = true;
      sunlight.shadow.camera.top = 180;
      sunlight.shadow.camera.bottom = -100;
      sunlight.shadow.camera.left = -120;
      sunlight.shadow.camera.right = 120;

      this.light = sunlight;
      return sunlight;
    }
    else if (lightType == 'HemisphereLight') {
      // let hemisphereLight = new HemisphereLight(0xffffff, 0x444444, 3.5);
      let hemisphereLight = new HemisphereLight(0xA2CD5A, 0x9A32CD, 1.2);
      hemisphereLight.position.set(0, 200, 0);
      this.light = hemisphereLight;
      return hemisphereLight;
    }
    else if (lightType == 'AmbientLight') {
      let ambientLight = new THREE.AmbientLight();
      ambientLight.position.set(0, 200, 0);
      this.light = ambientLight;
      return ambientLight;
    }
  }
}

export default LightMgr;
